<?php
use app\models\Mall;
use yii\helpers\Url;

$web = Url::base();
$institution_code = Mall::getCurrentInstitutionCode();

$this->title = '卡卷列表';

$goodsList = $result['goodsList'];
?>
<link rel="stylesheet" type="text/css" href="<?= $web ?>/css/mall/card-volume.css"/>



<div class="card-volume">
    <ul>
        <?php
        foreach ($goodsList as $item) {
        ?>
            <li>
                <a href="<?= Url::to(['mall/virtual-coupon-detail', 'shopId' => $item['shopId'], 'institution_code' => $institution_code]) ?>">
                    <img src="<?= $item['info']->picBg ?>"/>
                    <div class="message">
                        <p class="title"><?= $item['info']->title ?></p>
                        <p class="time">领取时间至：<?= date('Y-m-d', $item['info']->dateValidTo) ?></p>
                    </div>
                    <div class="price">
                        <p class="old-price">¥：<?= $item['info']->price ?></p>
                        <p class="now-price">免费领取</p>
                    </div>
                </a>
            </li>
        <?php
        }
        ?>

       <!-- <li>
            <a href="">
                <img src="imgs/card-volume.jpg"/>
                <div class="message">
                    <p class="title">100元养车大礼包</p>
                    <p class="time">领取时间至：2016-10-31</p>
                </div>
                <div class="price">
                    <p class="old-price">¥：100.00</p>
                    <p class="now-price">免费领取</p>
                </div>
            </a>
        </li>-->

    </ul>
</div>
<div class="clfl"></div>
<script>
    <?php
    $maxPage=intval($result['totalPage']);
    $page=intval($result['pageNo']);
    ?>
    function href_page(page) {
        var currentPage=<?=$page?>;
        page=parseInt(page);
        if(isNaN(page)){
            page=0;
        }
        if(page<1){
            page=1;
        }
        var maxPage=<?=$maxPage?>;
        if(page>maxPage){
            page=maxPage;
        }
        if(page==currentPage){
            return;
        }
        var href = window.location.href;
        href = setUrlParam(href, 'page', page);
        window.location.href = href;
    }
</script>

<div class="paging">
    <div class="pag-content">
        <div class="sum-page">
            <p class="total">共<?=$maxPage?>页</p>
            <p class="send">到第<input class="num" type="text" value=""/>页</p>
            <a href="javascript:href_page($('.num').val())" class="confirm-btn">确定</a>
        </div>
        <div class="page-list">
            <?php
            if($page>1){
                ?>
                <a href="javascript:href_page(<?=$page-1?>)" class="previous-page">< 上一页</a>
                <?php
            }
            ?>
            <div class="page-num">
                <?php
                $pagesList=\app\librarys\Tools::getJDPageNumList($page,$maxPage,6);
                foreach($pagesList as $item){
                    if($item=='preDot' || $item=='lastDot'){
                        echo '<span class="page-num-list">...</span>';
                    }else {
                        ?>
                        <a href="javascript:href_page(<?=$item?>)" class="page-num-list <?=(string)$page==$item ? '' :'page-border'?>"><?=$item?></a>
                        <?php
                    }
                }
                ?>

                <!--
                <a href="" class=" page-num-list">1</a>
                <a href="" class="page-border page-num-list">2</a>
                 <a  href="" class="page-border page-num-list">3</a>
                 <span class="page-num-list">...</span>
                 <a href="" class="page-border page-num-list">20</a>-->
            </div>
            <?php
            if($page<$maxPage){
                ?>
                <a href="javascript:href_page(<?=$page+1?>)" class="next-page">下一页 ></a>
                <?php
            }
            ?>
        </div>
    </div>
</div>


